package com.auxgroup.smarthome.business.controller;

import com.auxgroup.bridge.app.inner.vo.DeviceFaultVo;
import com.auxgroup.smarthome.business.service.inner.DeviceFaultInnerService;
import com.auxgroup.smarthome.utils.PageContent;
import com.auxgroup.smarthome.web.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 设备故障
 * Created by lixiaoxiao on 17-8-9.
 */
@Api(description = "设备故障", tags = "设备故障")
@RestController
public class ConsumerDeviceFaultController {

    @Autowired
    private DeviceFaultInnerService deviceFaultInnerService;

    @ApiOperation(value = "设备故障列表",notes = "设备故障--获取故障列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyword", value = "mac/用户名/手机号",  paramType = "query", dataType = "string",required = false),
            @ApiImplicitParam(name = "page", value = "页码",  paramType = "query", dataType = "integer",required = false),
            @ApiImplicitParam(name = "size", value = "分页大小",  paramType = "query", dataType = "integer",required = false),
            @ApiImplicitParam(name = "status", value = "状态(1: 未解决0: 已解决)",  paramType = "query", dataType = "integer",required = true)
    })
    @RequestMapping(value = "/device_fault", method = RequestMethod.GET)
    public ApiResponse<Page<DeviceFaultVo>> getDeviceFaultList(@RequestParam(required = false) String keyword,
                                                               @RequestParam(required = false) Integer page,
                                                               @RequestParam(required = false) Integer size,
                                                               @RequestParam(required = true) Integer status)
    {
        ApiResponse<PageContent<DeviceFaultVo>> apiResponse = deviceFaultInnerService.getDeviceFaultList(keyword, page,size,status);
        Page<DeviceFaultVo> pageContent = apiResponse.getData().convertPage();
        return new ApiResponse(apiResponse.getCode(), apiResponse.getMessage(), pageContent);
    }
}
